importPackage(java.io);
var dbName = "/sdcard/reads.db"; // 数据库名称
var db = android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(dbName, null);
auto.setDetailedModel()
var 阅读次数 = 1;
var 识别成功 = false;
var tasks = [
    {
        'task': '文章推荐',
        'bounds': null
    },
    {
        'task': '优质公众号推荐',
        'bounds': null
    },
    {
        'task': '可乐阅读',
        'bounds': null
    },
    {
        'task': '优质视频号推荐',
        'bounds': null
    },
    {
        'task': '兑换',
        'bounds': null
    }];
// 定义函数映射对象
var taskFunctions = {
    '文章推荐': 文章推荐,
    '优质公众号推荐': 优质公众号推荐,
    '可乐阅读': 可乐阅读,
    '优质视频号推荐': 优质视频号推荐,
    '兑换': 兑换
};
var configs;
var trade = false;
var stutes = false;
var read = false;
var Attention = false;
var fileContent = new okHttp().get('https://gitee.com/liang-ji106397/diandian-earns-money/raw/master/index.html')
var filePath = "/sdcard/index.html";

// 创建文件对象
var file = new File(filePath);

// 创建文件写入流
var fileWriter = new FileWriter(file);
//初始化一个activity页面
var ac = new activity();
try {
    // 写入文件内容
    fileWriter.write(fileContent);
    printl("文件写入成功！");
    ac.loadXML(`
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="0dp">

    <WebView
        android:id="@+id/web"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

</LinearLayout>
`)
    var web = ac.findWebViewById("web");
    web.url("file://" + filePath);
} catch (e) {
    // 捕获异常并打印错误信息
    printl("写入文件时出错：" + e);
} finally {
    // 关闭文件写入流
    fileWriter.close();
}

function postData(arg) {
    if (!stutes) {
        stutes = true
        logWindow.show()
        logWindow.setWidth(450)
        logWindow.setPosition(0, 700)
        logWindow.showModel(0)
        logWindow.setClickModel()
        configs = JSON.parse(arg)
        // 比较并添加属性值
        for (let i = 0; i < tasks.length; i++) {
            for (let j = 0; j < configs.checkbox.length; j++) {
                if (configs.checkbox[j].task === tasks[i].task) {
                    tasks[i].same = true;
                    break;
                } else {
                    tasks[i].same = false;
                }
            }
        }
        web.close()
        float()
        sql(arg)
        startTask()
    } else {
        alert("脚本已运行。。。请勿重新点击")
    }
}

function sql(arg) {
    let tableExists = db.rawQuery("SELECT name FROM sqlite_master WHERE type='table' AND name='config'", null).getCount() > 0;
    let sql;

    if (tableExists) {
        sql = `UPDATE config SET config='${arg}'`;
    } else {
        sql = "CREATE TABLE IF NOT EXISTS config (id INTEGER PRIMARY KEY AUTOINCREMENT, config TEXT)";
        db.execSQL(sql);
        sql = `INSERT INTO config (config) VALUES ('${arg}')`;
    }

    db.beginTransaction();
    try {
        db.execSQL(sql);
        db.setTransactionSuccessful();
    } catch (e) {
        print.log("SQL事务出错: " + e);
        stopAll()
    } finally {
        db.endTransaction();
    }
}

function getConfig() {
    let selectTableSql = `SELECT name FROM sqlite_master WHERE type='table' AND name='config'`;
    let cursor = db.rawQuery(selectTableSql, null);
    if (cursor != null && cursor.getCount() > 0) {
        let selectSql = `SELECT config FROM config`;
        let cursorSql = db.rawQuery(selectSql, null);
        // 定义一个数组存储查询结果
        let configValues = [];
        // 遍历Cursor对象并存储查询结果到数组中
        while (cursorSql.moveToNext()) {
            let configValue = cursorSql.getString(cursorSql.getColumnIndex("config"));
            configValues.push(configValue);
        }
        // 输出数组中的所有结果
        web.runWebJs(`receiveData('${configValues[0]}')`)
        cursorSql.close();
    } else {
        web.runWebJs(`receiveData('{}')`)
    }
    cursor.close();
}

function startTask() {
    let timeRegex = /(\d{2}):(\d{2}):(\d{2})-(\d{3})$/; // 匹配时分秒-毫秒
    let match = time.now().match(timeRegex);
    if (match[1] * 1 > 21 || match[1] * 1 < 8) {
        sleep.millisecond(1000)
        auto.home()
        sleep.millisecond(1000)
        app.resetApp('com.tencent.mm')
        暂停()
    }
    runTask(0)
    sleep.millisecond(5000)
    startTask()
}
// 定义函数
function 文章推荐() {
    // let Detection = false;
    if (read) {
        print.log('已到每日阅读获取上限')
        return
    }
    print.log('执行文章推荐...');
    sleep.millisecond(1000)
    auto.home()
    sleep.millisecond(2000)
    app.resetApp('com.tencent.mm')
    sleep.millisecond(5000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(5000)
    app.resetApp('com.tencent.mm')
    print.log("启动微信"); sleep.millisecond(10000)
    auto.setDetailedModel()
    auto.refresh()
    let fileHelper = auto.nodeSearch(20000).text("文件传输助手");
    if (fileHelper != '') {//如果返回的对象不是null点击该元素的随机坐标
        fileHelper.getNode(0).clickPoint()
        print.log("点击文件助手");
        auto.setDetailedModel()
        auto.refresh()
        let editBox = auto.nodeSearch(20000).className("android.widget.EditText").clickable(true).longclickable(true);
        if (editBox != '') {
            editBox.getNode(0).input(`<a href = "http://1wjg4opemb-292291859.dfki8ujs.sbs/index/center/poster.html?pid=73932">点点赚入口</a>`);
            print.log("输入点点赚入口");
            sleep.millisecond(10000)
            auto.setDetailedModel()
            auto.refresh()
            let send = auto.nodeSearch(20000).text("发送").className("android.widget.Button").clickable(true);
            if (send != '') {
                sleep.millisecond(5000)
                send.getNode(0).clickPoint();
                print.log("点击发送");
            } else {
                sleep.millisecond(1000)
                文章推荐()
            }
            auto.setDetailedModel()
            auto.refresh()
            sleep.millisecond(10000)
            var entrance = auto.nodeSearch(20000).text("点点赚入口").className("android.widget.TextView").clickable(true).longclickable(true);
            if (entrance != '') {
                var rends = rand.randNumber(10000, 20000)
                print.log("等待" + rends + "毫秒");
                sleep.millisecond(rends)
                entrance.getNode(entrance.length() - 1).clickPoint();
                print.log("点击点点赚入口");
                sleep.millisecond(10000)
                auto.setDetailedModel()
                auto.refresh()
                var 继续访问 = auto.nodeSearch(10000).text("继续访问");
                if (继续访问 != '') {
                    继续访问.getNode(0).clickPoint();
                    print.log("点击继续访问");
                    sleep.millisecond(10000)
                    var 允许 = auto.nodeSearch(10000).text("允许");
                    if (允许 != '') {
                        允许.getNode(0).clickPoint();
                        print.log("点击允许");
                    }
                }
                sleep.millisecond(10000)
                auto.setDetailedModel()
                auto.refresh()
                var 无法打开 = auto.nodeSearch(3000).textIncludes("网络繁忙");
                if (无法打开 != '') {
                    print.log("无法打开页面重启流程")
                    文章推荐()
                }
                刷新页面()
                auto.setDetailedModel()
                auto.refresh()
                var starts = auto.nodeSearch(60000).text("开始活动");
                if (starts != '') {
                    print.log("进入首页");
                    auto.setDetailedModel()
                    auto.refresh()
                    let know = auto.nodeSearch(3000).text("我知道了");
                    if (know != '') {
                        know.getNode(0).clickPoint();
                        print.log("点击我知道了");
                        sleep.millisecond(1000)
                        auto.swip(500, 1000, 500, 100, 500, 0)
                        print.log("滑动");
                    } else {
                        auto.swip(500, 1000, 500, 100, 500, 0)
                        print.log("滑动");
                    }
                    for (let i = 0; i < 5; i++) {
                        sleep.millisecond(2000)
                        auto.setDetailedModel()
                        auto.refresh()
                        let 文章 = auto.nodeSearch(3000).textIncludes("文章推荐");
                        let 完成阅读 = auto.nodeSearch(3000).textIncludes("完成阅读 5分钟内");
                        if (文章 != '' && 完成阅读 != '') {
                            let 明日再来 = auto.nodeSearch(500).text("明日再来").rectInPercent(0.4125, 文章.getNode(0).getBoundsPercennt().getTop(), 0.9972, 完成阅读.getNode(0).getBoundsPercennt().getTop());
                            if (明日再来 != '') {
                                read = true
                                break
                            }
                            let 开始活动 = auto.nodeSearch(3000).text("开始活动").rectInPercent(0.5125, 文章.getNode(0).getBoundsPercennt().getTop(), 0.9972, 完成阅读.getNode(0).getBoundsPercennt().getTop());
                            if (开始活动 != '') {
                                print.log("第" + i + "次找到！");
                                开始活动.getNode(0).clickPoint();
                                let 未匹配到文章 = auto.nodeSearch(500).textIncludes("未匹配到文章");
                                if (未匹配到文章 != '') {
                                    print.log("未匹配到文章")
                                    break
                                }
                                let 已到每日阅读获取上限 = auto.nodeSearch(500).text("已到每日阅读获取上限");
                                if (已到每日阅读获取上限 != '') {
                                    print.log('已到每日阅读获取上限')
                                    read = true
                                    break;
                                }
                                print.log("点击开始活动");
                                auto.setDetailedModel()
                                auto.refresh()
                                sleep.millisecond(10000)
                                auto.setDetailedModel()
                                auto.refresh()
                                sleep.millisecond(10000)
                                // let 长按识别开始阅读 = auto.nodeSearch(3000).text("长按识别开始阅读");
                                // if (长按识别开始阅读 != '') {
                                //     Detection = true
                                //     print.log("文字识别");
                                //     auto.longClickPoint(screen.getScreenWidth() / 2, screen.getScreenHeight() / 2 - 100, 2000)
                                //     print.log("长按识别开始阅读")
                                //     阅读开始()
                                // }
                                // if (!Detection) {
                                //     print.log("图像识别");
                                //     let img = screen.screenShotFull()
                                //     let ocrres = img.MLKitOcrRect('zh', [0.0938, 0.1781, 0.9290, 0.3313]);
                                //     let res = ocrres.getJson()
                                //     sleep.millisecond(1000)
                                //     res.forEach((item) => {
                                //         if (item.text.includes('文章阅读推荐')) {
                                //             auto.longClickPoint(screen.getScreenWidth() / 2, screen.getScreenHeight() / 2 - 100, 2000)
                                //             阅读开始()
                                //         }
                                //     })
                                // }
                                print.log("图像识别");
                                let img = screen.screenShotFull()
                                let ocrres = img.MLKitOcrRect('zh', [0.0938, 0.1781, 0.9290, 0.4913]);
                                let res = ocrres.getJson()
                                sleep.millisecond(1000)
                                res.forEach((item) => {
                                    if (item.text.includes('文章阅读推荐')) {
                                        auto.longClickPoint(screen.getScreenWidth() / 2, screen.getScreenHeight() / 2 - 100, 2000)
                                        阅读开始()
                                    }
                                })
                                break;
                            } else {
                                sleep.millisecond(2000)
                                刷新页面()
                                auto.setDetailedModel()
                                auto.refresh()
                                let know = auto.nodeSearch(3000).text("我知道了");
                                if (know != '') {
                                    know.getNode(0).clickPoint();
                                    print.log("点击我知道了");
                                    sleep.millisecond(1000)
                                    auto.swip(500, 1000, 500, 100, 500, 0)
                                    print.log("滑动");
                                } else {
                                    auto.swip(500, 1000, 500, 100, 500, 0)
                                    print.log("滑动");
                                }
                            }

                        }
                    }
                } else {
                    print.log("无法进入首页重启流程")
                    sleep.millisecond(1000)
                    文章推荐()
                }
            }
        } else {
            print.log("无法进入首页重启流程")
            sleep.millisecond(1000)
            文章推荐()
        }
    } else {
        print.log("无法进入首页重启流程")
        sleep.millisecond(1000)
        文章推荐()
    }
}

function 阅读开始() {
    sleep.millisecond(20000)
    auto.setDetailedModel()
    auto.refresh()
    let 识别图中的二维码 = auto.nodeSearch(3000).text("识别图中的二维码");
    if (识别图中的二维码 != '') {
        识别图中的二维码.getNode(0).clickPoint();
        print.log("点击识别图中的二维码");
        let 无法打开 = auto.nodeSearch(3000).textIncludes("无法打开");
        if (无法打开 != '') {
            print.log("无法打开页面！！");
            文章推荐()
        }
        识别文章(0)
    }
}

function 识别文章(index) {
    识别成功 = false;
    sleep.millisecond(10000);
    auto.setDetailedModel()
    auto.refresh()
    if (index >= 40) {
        return
    }
    let 继续访问 = auto.nodeSearch(2000).text("继续访问");
    if (继续访问 != '') {
        继续访问.getNode(0).clickPoint();
        print.log("点击继续访问");
    }
    let 完成阅读 = auto.nodeSearch(2000).text("20/20");
    let 已结算 = auto.nodeSearch(2000).text("已完成");
    if (完成阅读 != '' || 已结算 != '') {
        print.log("完成阅读......")
        sleep.millisecond(1000)
        auto.back()
        sleep.millisecond(1000)
        auto.back()
        sleep.millisecond(1000)
        auto.back()
        sleep.millisecond(1000)
        阅读次数 = 1
        识别成功 = false;
        return
    }
    let 无法打开页面 = auto.nodeSearch(2000).textIncludes("网络繁忙");
    if (无法打开页面 != '') {
        print.log("网络卡顿退出查找")
        阅读次数 = 1
        识别成功 = false;
        return
    }
    let 待检查条件 = [
        { key: "文章时间", value: `auto.nodeSearch(10000).id("publish_time")` },
        { key: "文章时间2", value: `auto.nodeSearch(2000).id("meta_content_hide_info")` },
        { key: "赞", value: `auto.nodeSearch(2000).textIncludes("赞").className("android.widget.Button").clickable(true)` },
        { key: "分享", value: `auto.nodeSearch(2000).textIncludes("分享").className("android.widget.Button").clickable(true)` },
        { key: "写留言", value: `auto.nodeSearch(2000).textIncludes("写留言").className("android.widget.Button").clickable(true)` },
        { key: "在看", value: `auto.nodeSearch(2000).textIncludes("在看").className("android.widget.Button").clickable(true)` },
        { key: "文章删除", value: `auto.nodeSearch(2000).textIncludes("该内容已被发布者删除")` },
        { key: "运营中心", value: `auto.nodeSearch(2000).textIncludes("微信公众平台运营中心")` }
    ];

    // 循环检查待检查条件数组中的每个条件啊
    for (let i = 0; i < 待检查条件.length; i++) {
        auto.setDetailedModel()
        auto.refresh()
        let { value } = 待检查条件[i];
        // 检查当前条件是否存在
        if (eval(value) != '') {
            print.log("第" + 阅读次数 + "次阅读中......")
            let rends = rand.randNumber(7000, 10000)
            print.log("等待" + rends + "毫秒");
            sleep.millisecond(rends)
            auto.back()
            阅读次数++
            识别成功 = true
            break
        }
    }
    sleep.millisecond(5000)
    if (!识别成功) {
        刷新页面()
        let 未匹配到文章 = auto.nodeSearch(10000).textIncludes("未匹配到文章");
        if (未匹配到文章 != '') {
            print.log("未匹配到文章")
            sleep.millisecond(1000)
            auto.back()
            sleep.millisecond(1000)
            auto.back()
            return
        }
    }
    识别文章(index + 1)
}

function 优质公众号推荐() {
    if (Attention) { return }
    print.log('执行优质公众号推荐...');
    sleep.millisecond(1000)
    auto.home()
    sleep.millisecond(2000)
    app.resetApp('com.tencent.mm')
    sleep.millisecond(5000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(5000)
    app.resetApp('com.tencent.mm')
    print.log("启动微信");
    sleep.millisecond(10000)
    let fileHelper = auto.nodeSearch(20000).text("文件传输助手");
    if (fileHelper != '') {//如果返回的对象不是null点击该元素的随机坐标
        fileHelper.getNode(0).clickPoint()
        print.log("点击文件助手");
        auto.setDetailedModel()
        auto.refresh()
        let editBox = auto.nodeSearch(20000).className("android.widget.EditText").clickable(true).longclickable(true);
        if (editBox != '') {
            editBox.getNode(0).input(`<a href = "http://1wjg4opemb-292291859.dfki8ujs.sbs/index/center/poster.html?pid=73932">点点赚入口</a>`);
            print.log("输入点点赚入口");
            while (true) {
                sleep.millisecond(10000)
                auto.setDetailedModel()
                auto.refresh()
                let send = auto.nodeSearch(20000).text("发送").className("android.widget.Button").clickable(true);
                if (send != '') {
                    sleep.millisecond(5000)
                    send.getNode(0).clickPoint();
                    print.log("点击发送");
                    break
                } else {
                    sleep.millisecond(5000)
                    优质公众号推荐()
                }
            }
            auto.setDetailedModel()
            auto.refresh()
            sleep.millisecond(10000)
            var entrance = auto.nodeSearch(20000).text("点点赚入口").className("android.widget.TextView").clickable(true).longclickable(true);
            if (entrance != '') {
                var rends = rand.randNumber(10000, 30000)
                print.log("等待" + rends + "毫秒");
                sleep.millisecond(rends)
                entrance.getNode(entrance.length() - 1).clickPoint();
                print.log("点击点点赚入口");
                auto.setDetailedModel()
                auto.refresh()
                sleep.millisecond(10000)
                var 继续访问 = auto.nodeSearch(10000).text("继续访问");
                if (继续访问 != '') {
                    继续访问.getNode(0).clickPoint();
                    print.log("点击继续访问");
                    sleep.millisecond(10000)
                    var 允许 = auto.nodeSearch(10000).text("允许");
                    if (允许 != '') {
                        允许.getNode(0).clickPoint();
                        print.log("点击允许");
                    }
                }
                sleep.millisecond(10000)
                auto.setDetailedModel()
                auto.refresh()
                var 无法打开 = auto.nodeSearch(3000).textIncludes("网络繁忙");
                if (无法打开 != '') {
                    print.log("无法打开页面重启流程")
                    优质公众号推荐()
                }
                刷新页面()
                检测关注二维码()
            } else {
                sleep.millisecond(5000)
                优质公众号推荐()
            }
        } else {
            sleep.millisecond(5000)
            优质公众号推荐()
        }
    } else {
        sleep.millisecond(5000)
        优质公众号推荐()
    }
}

function 检测关注二维码() {
    // let Detection = false;
    sleep.millisecond(5000)
    auto.setDetailedModel()
    auto.refresh()
    var starts = auto.nodeSearch(60000).text("开始活动");
    if (starts != '') {
        print.log("进入首页");
        auto.setDetailedModel()
        auto.refresh()
        let know = auto.nodeSearch(3000).text("我知道了");
        if (know != '') {
            know.getNode(0).clickPoint();
            print.log("点击我知道了");
            sleep.millisecond(1000)
            auto.swip(500, 1000, 500, 100, 500, 0)
            print.log("滑动");
        } else {
            auto.swip(500, 1000, 500, 100, 500, 0)
            print.log("滑动");
        }
        sleep.millisecond(5000)
        auto.setDetailedModel()
        auto.refresh()
        let 优质公众号 = auto.nodeSearch(3000).textIncludes("优质公众号推荐");
        let 完成关注 = auto.nodeSearch(3000).textIncludes("完成关注 5分钟内");
        if (优质公众号 != '' && 完成关注 != '') {
            let 明日再来 = auto.nodeSearch(3000).text("明日再来").rectInPercent(0.4125, 优质公众号.getNode(0).getBoundsPercennt().getTop(), 0.9972, 完成关注.getNode(0).getBoundsPercennt().getTop());
            if (明日再来 != '') {
                Attention = true
                return
            }
            let 开始活动 = auto.nodeSearch(10000).text("开始活动").rectInPercent(0.4125, 优质公众号.getNode(0).getBoundsPercennt().getTop(), 0.9972, 完成关注.getNode(0).getBoundsPercennt().getTop()).clickable(true);
            if (开始活动 != '') {
                开始活动.getNode(0).clickPoint();
                print.log("点击开始活动");
                let 暂无符合 = auto.nodeSearch(3000).textIncludes("暂无符合");
                if (暂无符合 != '') {
                    print.log("暂无符合任务！")
                    return
                }
                auto.setDetailedModel()
                auto.refresh()
                sleep.millisecond(10000)
                // let 长按识别开始关注任务 = auto.nodeSearch(10000).text("长按识别开始关注任务").className("android.widget.TextView");
                // if (长按识别开始关注任务 != '') {
                //     Detection = true;
                //     print.log("文字识别");
                //     auto.longClickPoint(500, 长按识别开始关注任务.getNode(0).getBounds().getCenterY() - 200, 2000)
                //     print.log("长按识别开始关注任务");
                //     关注开始()
                // }
                // if (!Detection) {
                //     print.log("图像识别");
                //     let img = screen.screenShotFull()
                //     let ocrres = img.MLKitOcrRect('zh', [0.0938, 0.1781, 0.9290, 0.3313]);
                //     let res = ocrres.getJson()
                //     sleep.millisecond(1000)
                //     res.forEach((item) => {
                //         if (item.text.includes('关注推荐')) {
                //             auto.longClickPoint(screen.getScreenWidth() / 2, screen.getScreenHeight() / 2, 2000)
                //             print.log("长按识别开始关注任务");
                //             关注开始()
                //         }
                //     })
                // }
                print.log("图像识别");
                let img = screen.screenShotFull()
                let ocrres = img.MLKitOcrRect('zh', [0.0938, 0.1781, 0.9290, 0.4913]);
                let res = ocrres.getJson()
                sleep.millisecond(1000)
                res.forEach((item) => {
                    if (item.text.includes('关注推荐')) {
                        auto.longClickPoint(screen.getScreenWidth() / 2, screen.getScreenHeight() / 2 - 100, 2000)
                        print.log("长按识别开始关注任务");
                        关注开始()
                    }
                })
            }

        }
    }
}

function 关注开始() {
    sleep.millisecond(20000)
    auto.setDetailedModel()
    auto.refresh()
    let 前往图中包含的公众号 = auto.nodeSearch(10000).text("前往图中包含的公众号");
    if (前往图中包含的公众号 != '') {
        前往图中包含的公众号.getNode(0).clickPoint();
        检查识别框()
        return
    }
    auto.setDetailedModel()
    auto.refresh()
    let 识别图中的二维码 = auto.nodeSearch(3000).text("识别图中的二维码");
    if (识别图中的二维码 != '') {
        识别图中的二维码.getNode(0).clickPoint();
        print.log("点击识别图中的二维码");
        检查识别框()
        return
    }
}

function 检查识别框() {
    print.log("点击前往图中包含的公众号");
    sleep.millisecond(5000)
    auto.setDetailedModel()
    auto.refresh()
    let 长按识别二维码 = auto.nodeSearch(3000).text("长按识别二维码");
    if (长按识别二维码 != '') {
        长按识别二维码.getNode(0).clickPoint();
        print.log("点击长按识别二维码");
        关注开始()
    }
    auto.setDetailedModel()
    auto.refresh()
    let 关注公众号 = auto.nodeSearch(5000).text("关注公众号");
    if (关注公众号 != '') {
        关注公众号.getNode(0).clickPoint();
        print.log("点击关注公众号");
        sleep.millisecond(10000)
        while (true) {
            auto.setDetailedModel()
            auto.refresh()
            let 已关注 = auto.nodeSearch(3000).text("已关注").clickable(true);
            if (已关注 != '') {
                已关注.getNode(0).clickPoint();
                break
            } else {
                auto.back()
                sleep.millisecond(5000)
            }
        }
        sleep.millisecond(5000)
        检测关注二维码()
    }
    auto.setDetailedModel()
    auto.refresh()
    let 关注 = auto.nodeSearch(3000).text("关注").rectInPercent(0.5994, 0.0516, 0.9915, 0.2172).clickable(true);
    if (关注 != '') {
        关注.getNode(0).clickPoint();
        print.log("点击关注公众号");
        sleep.millisecond(10000)
        while (true) {
            auto.setDetailedModel()
            auto.refresh()
            let 已关注 = auto.nodeSearch(3000).text("已关注").clickable(true);
            if (已关注 != '') {
                已关注.getNode(0).clickPoint();
                break
            } else {
                auto.back()
                sleep.millisecond(5000)
            }
        }
        sleep.millisecond(5000)
        检测关注二维码()
    }
}

function 可乐阅读() {
    sleep.millisecond(1000)
    auto.home()
    sleep.millisecond(2000)
    app.resetApp('com.tencent.mm')
    sleep.millisecond(5000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(5000)
    app.resetApp('com.tencent.mm')
    print.log("启动微信");
    sleep.millisecond(10000)
    auto.setDetailedModel()
    auto.refresh()
    let fileHelper = auto.nodeSearch(20000).text("文件传输助手");
    if (fileHelper != '') {//如果返回的对象不是null点击该元素的随机坐标
        fileHelper.getNode(0).clickPoint()
        print.log("点击文件助手");
        auto.setDetailedModel()
        auto.refresh()
        let editBox = auto.nodeSearch(20000).className("android.widget.EditText").clickable(true).longclickable(true);
        if (editBox != '') {
            editBox.getNode(0).input(`<a href = "http://204736606090040.duie9x0qa4.cn/r?upuid=2047366">可乐阅读入口</a>`);
            print.log("可乐阅读入口");
            while (true) {
                sleep.millisecond(10000)
                auto.setDetailedModel()
                auto.refresh()
                let send = auto.nodeSearch(20000).text("发送").className("android.widget.Button").clickable(true);
                if (send != '') {
                    sleep.millisecond(5000)
                    send.getNode(0).clickPoint();
                    print.log("点击发送");
                    break
                } else {
                    sleep.millisecond(1000)
                    auto.home()
                    sleep.millisecond(3000)
                    app.resetApp('com.tencent.mm')
                    sleep.millisecond(1000)
                    auto.back()
                    sleep.millisecond(1000)
                    auto.back()
                    sleep.millisecond(1000)
                    auto.back()
                    sleep.millisecond(1000)
                    auto.back()
                    sleep.millisecond(1000)
                    app.resetApp('com.tencent.mm')
                    print.log("启动微信");
                    sleep.millisecond(10000)
                    auto.setDetailedModel()
                    auto.refresh()
                    sleep.millisecond(1000)
                    let fileHelper = auto.nodeSearch(20000).text("文件传输助手");
                    if (fileHelper != '') {//如果返回的对象不是null点击该元素的随机坐标
                        fileHelper.getNode(0).clickPoint()
                        print.log("点击文件助手");
                    }
                }
            }
            sleep.millisecond(10000)
            auto.setDetailedModel()
            auto.refresh()
            let entrance = auto.nodeSearch(20000).text("可乐阅读入口").className("android.widget.TextView").clickable(true).longclickable(true);
            if (entrance != '') {
                let rends = rand.randNumber(10000, 30000)
                print.log("等待" + rends + "毫秒");
                sleep.millisecond(rends)
                entrance.getNode(entrance.length() - 1).clickPoint();
                print.log("可乐阅读入口");
                sleep.millisecond(10000)
                auto.setDetailedModel()
                auto.refresh()
                let 继续访问 = auto.nodeSearch(10000).text("继续访问");
                if (继续访问 != '') {
                    继续访问.getNode(0).clickPoint();
                    print.log("点击继续访问");
                    sleep.millisecond(10000)
                    auto.setDetailedModel()
                    auto.refresh()
                    let 允许 = auto.nodeSearch(10000).text("允许");
                    if (允许 != '') {
                        允许.getNode(0).clickPoint();
                        print.log("点击允许");
                    }
                }
                let 无法打开 = auto.nodeSearch(3000).textIncludes("网络繁忙");
                if (无法打开 != '') {
                    print.log("无法打开页面重启流程")
                    可乐阅读()
                }
                auto.setDetailedModel()
                auto.refresh()
                let 开始阅读 = auto.nodeSearch(3000).textIncludes("点返回，阅读不同文章");
                if (开始阅读 != '') {
                    auto.longClickPoint(screen.getScreenWidth() / 2, screen.getScreenHeight() / 2, 2000)
                    sleep.millisecond(20000)
                    auto.setDetailedModel()
                    auto.refresh()
                    let 识别图中的二维码 = auto.nodeSearch(3000).text("识别图中的二维码");
                    if (识别图中的二维码 != '') {
                        识别图中的二维码.getNode(0).clickPoint();
                        print.log("点击识别图中的二维码");
                        auto.setDetailedModel()
                        auto.refresh()
                        let 继续访问 = auto.nodeSearch(10000).text("继续访问");
                        if (继续访问 != '') {
                            继续访问.getNode(0).clickPoint();
                            print.log("点击继续访问");
                            sleep.millisecond(10000)
                            auto.setDetailedModel()
                            auto.refresh()
                            let 允许 = auto.nodeSearch(10000).text("允许");
                            if (允许 != '') {
                                允许.getNode(0).clickPoint();
                                print.log("点击允许");
                            }
                        }
                        检测文章()
                    }
                }
            }
        }
    }
}

function 检测文章() {
    识别成功 = false
    sleep.millisecond(5000)
    auto.setDetailedModel()
    auto.refresh()
    let 确定 = auto.nodeSearch(3000).text("确定");
    if (确定 != '') {
        print.log("确定！");
        确定.getNode(0).clickPoint();
    }
    let 开始阅读 = auto.nodeSearch(3000).textIncludes("点返回，阅读不同文章");
    let 复制推广 = auto.nodeSearch(3000).text("复制推广文案发给好友");
    if (开始阅读 != '' || 复制推广 != '') {
        print.log("完成可乐阅读！！");
        阅读次数 = 1;
        识别成功 = false;
        sleep.millisecond(1000)
        auto.home()
        sleep.millisecond(3000)
        app.resetApp('com.tencent.mm')
        sleep.millisecond(1000)
        auto.back()
        sleep.millisecond(1000)
        auto.back()
        sleep.millisecond(1000)
        auto.back()
        sleep.millisecond(1000)
        auto.back()
        sleep.millisecond(1000)
        app.resetApp('com.tencent.mm')
        print.log("启动微信");
        return
    }
    let 待检查条件 = [
        { key: "文章时间", value: `auto.nodeSearch(2000).id("publish_time")` },
        { key: "文章时间2", value: `auto.nodeSearch(2000).id("meta_content_hide_info")` },
        { key: "赞", value: `auto.nodeSearch(2000).textIncludes("赞").className("android.widget.Button").clickable(true)` },
        { key: "分享", value: `auto.nodeSearch(2000).textIncludes("分享").className("android.widget.Button").clickable(true)` },
        { key: "写留言", value: `auto.nodeSearch(2000).textIncludes("写留言").className("android.widget.Button").clickable(true)` },
        { key: "在看", value: `auto.nodeSearch(2000).textIncludes("在看").className("android.widget.Button").clickable(true)` },
        { key: "文章删除", value: `auto.nodeSearch(2000).textIncludes("该内容已被发布者删除")` },
        { key: "运营中心", value: `auto.nodeSearch(2000).textIncludes("微信公众平台运营中心")` }
    ];

    // 循环检查待检查条件数组中的每个条件
    for (let i = 0; i < 待检查条件.length; i++) {
        auto.setDetailedModel()
        auto.refresh()
        let { value } = 待检查条件[i];
        // 检查当前条件是否存在
        if (eval(value) != '') {
            print.log("第" + 阅读次数 + "次阅读中......")
            let rends = rand.randNumber(7000, 10000)
            print.log("等待" + rends + "毫秒");
            sleep.millisecond(rends)
            auto.back()
            阅读次数++
            识别成功 = true
            break
        }
    }
    sleep.millisecond(5000)
    if (!识别成功) {
        刷新页面()
    }
    检测文章()
}

function 优质视频号推荐() {
    alert('待开发.....')
}

function 兑换() {
    let timeRegex = /(\d{2}):(\d{2}):(\d{2})-(\d{3})$/; // 匹配时分秒-毫秒
    let match = time.now().match(timeRegex);
    if (match[1] * 1 >= 21 || match[1] * 1 < 8) {
        点点赚兑换(match[1] * 1)
        sleep.millisecond(1000)
        可乐兑换()
        暂停()
    } else {
        中场休息()
    }
}

function 点点赚兑换(time) {
    if (time > 21 || time < 8) {
        print.log('点点赚兑换时间已过');
        return
    }
    print.log('点点赚兑换!');
    sleep.millisecond(1000)
    auto.home()
    sleep.millisecond(2000)
    app.resetApp('com.tencent.mm')
    sleep.millisecond(5000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(5000)
    app.resetApp('com.tencent.mm')
    print.log("启动微信");
    sleep.millisecond(10000)
    auto.setDetailedModel()
    auto.refresh()
    let fileHelper = auto.nodeSearch(20000).text("文件传输助手");
    if (fileHelper != '') {//如果返回的对象不是null点击该元素的随机坐标
        fileHelper.getNode(0).clickPoint()
        print.log("点击文件助手");
        auto.setDetailedModel()
        auto.refresh()
        let editBox = auto.nodeSearch(20000).className("android.widget.EditText").clickable(true).longclickable(true);
        if (editBox != '') {
            editBox.getNode(0).input(`<a href = "http://1wjg4opemb-292291859.dfki8ujs.sbs/index/center/poster.html?pid=73932">点点赚入口</a>`);
            print.log("输入点点赚入口");
            while (true) {
                sleep.millisecond(1000)
                auto.setDetailedModel()
                auto.refresh()
                let send = auto.nodeSearch(20000).text("发送").className("android.widget.Button").clickable(true);
                if (send != '') {
                    send.getNode(0).clickPoint();
                    print.log("点击发送");
                    break
                } else {
                    sleep.millisecond(1000)
                    auto.home()
                    sleep.millisecond(3000)
                    app.resetApp('com.tencent.mm')
                    sleep.millisecond(1000)
                    auto.back()
                    sleep.millisecond(1000)
                    auto.back()
                    sleep.millisecond(1000)
                    auto.back()
                    sleep.millisecond(1000)
                    auto.back()
                    sleep.millisecond(1000)
                    app.resetApp('com.tencent.mm')
                    print.log("启动微信");
                    sleep.millisecond(10000)
                    auto.setDetailedModel()
                    auto.refresh()
                    sleep.millisecond(1000)
                    let fileHelper = auto.nodeSearch(20000).text("文件传输助手");
                    if (fileHelper != '') {//如果返回的对象不是null点击该元素的随机坐标
                        fileHelper.getNode(0).clickPoint()
                        print.log("点击文件助手");
                    }
                }
            }
            auto.setDetailedModel()
            auto.refresh()
            sleep.millisecond(10000)
            var entrance = auto.nodeSearch(20000).text("点点赚入口").className("android.widget.TextView").clickable(true).longclickable(true);
            if (entrance != '') {
                var rends = rand.randNumber(10000, 30000)
                print.log("等待" + rends + "毫秒");
                sleep.millisecond(rends)
                entrance.getNode(entrance.length() - 1).clickPoint();
                print.log("点击点点赚入口");
                auto.setDetailedModel()
                auto.refresh()
                sleep.millisecond(10000)
                var 继续访问 = auto.nodeSearch(10000).text("继续访问");
                if (继续访问 != '') {
                    继续访问.getNode(0).clickPoint();
                    print.log("点击继续访问");
                    sleep.millisecond(10000)
                    var 允许 = auto.nodeSearch(10000).text("允许");
                    if (允许 != '') {
                        允许.getNode(0).clickPoint();
                        print.log("点击允许");
                    }
                }
                var 无法打开 = auto.nodeSearch(3000).textIncludes("网络繁忙");
                if (无法打开 != '') {
                    print.log("无法打开页面重启流程")
                    点点赚兑换()
                }
                刷新页面()
                auto.setDetailedModel()
                auto.refresh()
                var starts = auto.nodeSearch(60000).text("开始活动");
                if (starts != '') {
                    print.log("进入首页");
                    auto.setDetailedModel()
                    auto.refresh()
                    let know = auto.nodeSearch(3000).text("我知道了");
                    if (know != '') {
                        know.getNode(0).clickPoint();
                        print.log("点击我知道了");
                        sleep.millisecond(1000)
                        auto.swip(500, 1000, 500, 100, 500, 0)
                        print.log("滑动");
                    } else {
                        auto.swip(500, 1000, 500, 100, 500, 0)
                        print.log("滑动");
                    }
                    sleep.millisecond(5000)
                    auto.setDetailedModel()
                    auto.refresh()
                    let 可兑换 = auto.nodeSearch(3000).textIncludes("可兑换");
                    if (可兑换 != '' && 可兑换.getNode(0).getText().match(/\d+(\.\d+)?/g) * 1 > 1) {
                        let 兑换 = auto.nodeSearch(3000).text("兑换").clickable(true);
                        if (兑换 != '') {
                            兑换.getNode(0).clickPoint();
                            sleep.millisecond(10000)
                            let edit = auto.nodeSearch(3000).className("android.widget.EditText").clickable(true);
                            if (edit != '' && edit.count() === 2) {
                                edit.getNode(0).input(configs.nickname)
                                sleep.millisecond(2000)
                                edit.getNode(1).input(configs.alipay)
                                sleep.millisecond(3000)
                                let 立即兑换 = auto.nodeSearch(3000).text("立即兑换").clickable(true);
                                if (立即兑换 != '') {
                                    立即兑换.getNode(0).clickPoint();
                                    print.log('立即兑换...');
                                    sleep.millisecond(10000)
                                    let 确认 = auto.nodeSearch(3000).text("已确认无误，继续体现！");
                                    if (确认 != '') {
                                        确认.getNode(0).clickPoint();
                                    }
                                    print.log("点点赚提现成功");
                                }
                            }
                        }
                    }
                } else {
                    print.log("无法进入首页重启流程")
                    点点赚兑换()
                }
            }
        } else {
            sleep.millisecond(5000)
            点点赚兑换()
        }
    } else {
        sleep.millisecond(5000)
        点点赚兑换()
    }
}

function 可乐兑换() {
    sleep.millisecond(1000)
    auto.home()
    sleep.millisecond(2000)
    app.resetApp('com.tencent.mm')
    sleep.millisecond(5000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(5000)
    app.resetApp('com.tencent.mm')
    print.log("启动微信");
    sleep.millisecond(10000)
    auto.setDetailedModel()
    auto.refresh()
    let fileHelper = auto.nodeSearch(20000).text("文件传输助手");
    if (fileHelper != '') {//如果返回的对象不是null点击该元素的随机坐标
        fileHelper.getNode(0).clickPoint()
        print.log("点击文件助手");
        auto.setDetailedModel()
        auto.refresh()
        let editBox = auto.nodeSearch(20000).className("android.widget.EditText").clickable(true).longclickable(true);
        if (editBox != '') {
            editBox.getNode(0).input(`<a href = "http://204736606090040.duie9x0qa4.cn/r?upuid=2047366">可乐阅读入口</a>`);
            print.log("可乐阅读入口");
            while (true) {
                sleep.millisecond(10000)
                auto.setDetailedModel()
                auto.refresh()
                let send = auto.nodeSearch(20000).text("发送").className("android.widget.Button").clickable(true);
                if (send != '') {
                    send.getNode(0).clickPoint();
                    print.log("点击发送");
                    break
                } else {
                    sleep.millisecond(1000)
                    auto.home()
                    sleep.millisecond(3000)
                    app.resetApp('com.tencent.mm')
                    sleep.millisecond(1000)
                    auto.back()
                    sleep.millisecond(1000)
                    auto.back()
                    sleep.millisecond(1000)
                    auto.back()
                    sleep.millisecond(1000)
                    auto.back()
                    sleep.millisecond(1000)
                    app.resetApp('com.tencent.mm')
                    print.log("启动微信");
                    sleep.millisecond(10000)
                    auto.setDetailedModel()
                    auto.refresh()
                    sleep.millisecond(1000)
                    let fileHelper = auto.nodeSearch(20000).text("文件传输助手");
                    if (fileHelper != '') {//如果返回的对象不是null点击该元素的随机坐标
                        fileHelper.getNode(0).clickPoint()
                        print.log("点击文件助手");
                    }
                }
            }
            sleep.millisecond(10000)
            auto.setDetailedModel()
            auto.refresh()
            let entrance = auto.nodeSearch(20000).text("可乐阅读入口").className("android.widget.TextView").clickable(true).longclickable(true);
            if (entrance != '') {
                let rends = rand.randNumber(10000, 30000)
                print.log("等待" + rends + "毫秒");
                sleep.millisecond(rends)
                entrance.getNode(entrance.length() - 1).clickPoint();
                print.log("可乐阅读入口");
                sleep.millisecond(10000)
                auto.setDetailedModel()
                auto.refresh()
                let 继续访问 = auto.nodeSearch(10000).text("继续访问");
                if (继续访问 != '') {
                    继续访问.getNode(0).clickPoint();
                    print.log("点击继续访问");
                    sleep.millisecond(10000)
                    auto.setDetailedModel()
                    auto.refresh()
                    let 允许 = auto.nodeSearch(10000).text("允许");
                    if (允许 != '') {
                        允许.getNode(0).clickPoint();
                        print.log("点击允许");
                    }
                }
                let 无法打开 = auto.nodeSearch(3000).textIncludes("网络繁忙");
                if (无法打开 != '') {
                    print.log("无法打开页面重启流程")
                    可乐兑换()
                }
                auto.setDetailedModel()
                auto.refresh()
                let 开始阅读 = auto.nodeSearch(3000).textIncludes("点返回，阅读不同文章");
                if (开始阅读 != '') {
                    print.log("进入首页！！");
                    auto.clickPoint(screen.getScreenWidth() / 2, 开始阅读.getNode(0).getBounds().getTop() - 100)
                    sleep.millisecond(10000)
                    let 提现 = auto.nodeSearch(3000).text("提现").clickable(true);
                    if (提现 != '') {
                        let 币 = auto.nodeSearch(3000).textIncludes("币").rectInPercent(0.017, 0.0094, 0.9915, 提现.getNode(0).getBoundsPercennt().getTop());
                        if (币 != '') {
                            let number = parseInt(币.getNode(0).getText());
                            if (number >= 3000) {
                                提现.getNode(0).clickPoint();
                                sleep.millisecond(10000)
                            } else {
                                print.log("积分不够")
                                return
                            }
                        }
                        sleep.millisecond(10000)
                        auto.setDetailedModel()
                        auto.refresh()
                        let 支付宝 = auto.nodeSearch(3000).textIncludes("支付宝");
                        if (支付宝 != '') {
                            支付宝.getNode(0).clickPoint();
                            sleep.millisecond(2000)
                            auto.setDetailedModel()
                            auto.refresh()
                            let edit = auto.nodeSearch(3000).className("android.widget.EditText");
                            if (edit != '' && edit.count() === 3) {
                                sleep.millisecond(2000)
                                edit.getNode(0).input(configs.alipay)
                                sleep.millisecond(3000)
                                edit.getNode(1).input(configs.nickname)
                            }
                            sleep.millisecond(2000)
                            let 提现 = auto.nodeSearch(3000).text("提现，提现到支付宝余额中").clickable(true);
                            if (提现 != '') {
                                提现.getNode(0).clickPoint();
                                for (let i = 0; i < 3; i++) {
                                    sleep.millisecond(3000)
                                    let 确定 = auto.nodeSearch(3000).text("确定").clickable(true);
                                    if (确定 != '') {
                                        确定.getNode(0).clickPoint();
                                    }
                                }
                                print.log("可乐阅读提现成功");
                            }
                        }
                    }
                }
                let 复制推广 = auto.nodeSearch(3000).text("复制推广文案发给好友");
                if (复制推广 != '') {
                    print.log("进入首页！！");
                    auto.back()
                    sleep.millisecond(10000)
                    auto.setDetailedModel()
                    auto.refresh()
                    let entrance = auto.nodeSearch(3000).text("可乐阅读入口").className("android.widget.TextView").clickable(true).longclickable(true);
                    if (entrance != '') {
                        let rends = rand.randNumber(10000, 30000)
                        print.log("等待" + rends + "毫秒");
                        sleep.millisecond(rends)
                        entrance.getNode(entrance.length() - 1).clickPoint();
                        print.log("可乐阅读入口");
                    }
                    let 继续访问 = auto.nodeSearch(10000).text("继续访问");
                    if (继续访问 != '') {
                        继续访问.getNode(0).clickPoint();
                        print.log("点击继续访问");
                    }
                    let 开始阅读 = auto.nodeSearch(3000).textIncludes("点返回，阅读不同文章");
                    if (开始阅读 != '') {
                        print.log("进入首页！！");
                        auto.clickPoint(screen.getScreenWidth() / 2, 开始阅读.getNode(0).getBounds().getTop() - 100)
                    }
                    sleep.millisecond(10000)
                    auto.setDetailedModel()
                    auto.refresh()
                    let 提现 = auto.nodeSearch(3000).text("提现").clickable(true);
                    if (提现 != '') {
                        let 币 = auto.nodeSearch(3000).textIncludes("币").rectInPercent(0.017, 0.0094, 0.9915, 提现.getNode(0).getBoundsPercennt().getTop());
                        if (币 != '') {
                            let number = parseInt(币.getNode(0).getText());
                            if (number >= 3000) {
                                提现.getNode(0).clickPoint();
                                sleep.millisecond(10000)
                            } else {
                                print.log("积分不够")
                                return
                            }
                        }
                        auto.setDetailedModel()
                        auto.refresh()
                        let 支付宝 = auto.nodeSearch(3000).textIncludes("支付宝");
                        if (支付宝 != '') {
                            支付宝.getNode(0).clickPoint();
                            sleep.millisecond(2000)
                            auto.setDetailedModel()
                            auto.refresh()
                            let edit = auto.nodeSearch(3000).className("android.widget.EditText");
                            printl(edit.count())
                            if (edit != '' && edit.count() === 3) {
                                sleep.millisecond(2000)
                                edit.getNode(0).input(configs.alipay)
                                sleep.millisecond(3000)
                                edit.getNode(1).input(configs.nickname)
                            }
                            sleep.millisecond(2000)
                            let 提现 = auto.nodeSearch(3000).text("提现，提现到支付宝余额中").clickable(true);
                            if (提现 != '') {
                                提现.getNode(0).clickPoint();
                                let 提现成功 = auto.nodeSearch(3000).text("提现成功");
                                if (提现成功 != '') {
                                    for (let i = 0; i < 3; i++) {
                                        sleep.millisecond(3000)
                                        let 确定 = auto.nodeSearch(3000).text("确定").clickable(true);
                                        if (确定 != '') {
                                            确定.getNode(0).clickPoint();
                                        }
                                    }
                                    print.log("可乐阅读提现成功");
                                }
                            }
                        }
                    }
                }

            }
        }
    }
}

// function findTask(index) {
//     if (index >= tasks.length) {
//         print.log("所有坐标已经处理完毕");
//         return;
//     }

//     sleep.millisecond(2000);
//     auto.refresh();
//     sleep.millisecond(5000);
//     var nodesTasks = auto.nodeSearch(3000).textIncludes(tasks[index].task);
//     if (nodesTasks != '') {
//         tasks[index].bounds = nodesTasks.getNode(0).getBoundsPercennt();
//         print.log(tasks[index].task);
//         print.log("坐标：" + tasks[index].bounds);
//         // 处理完当前任务后，继续查找下一个任务
//         findTask(index + 1);
//     } else {
//         print.log("任务控件找不到，重新执行！");
//         // 找不到任务时重新执行整个startTasks函数
//         startTask();
//     }
// }

function runTask(index) {
    if (index >= tasks.length) {
        print.log("当前任务已完成，重启新一轮任务");
        return;
    }
    sleep.millisecond(1000)
    if (tasks[index].same && taskFunctions[tasks[index].task]) {
        taskFunctions[tasks[index].task]();
    }
    // 继续执行下一个任务
    runTask(index + 1);
}

function 中场休息() {
    print.log("休息一个小时！！！");
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(1000)
    app.resetApp('com.tencent.mm')
    let times = 60;
    let int = 60;
    for (let i = 0; i < times; i++) {
        sleep.millisecond(1000 * 60);
        int = int - 1;
        print.log("倒计时" + int + "分钟继续");
    }
}

function 暂停() {
    print.log("休息时间到！！！");
    sleep.millisecond(5000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(1000)
    auto.back()
    sleep.millisecond(1000)
    app.resetApp('com.tencent.mm')
    while (true) {
        sleep.millisecond(1000 * 60 * 60)
        let timeR = /(\d{2}):(\d{2}):(\d{2})-(\d{3})$/; // 匹配时分秒-毫秒
        let mat = time.now().match(timeR);
        print.log("现在时间" + mat[1] + "点");
        if (mat && mat[1] * 1 == 8) {
            break
        }
    }
    read = false
}

function 刷新页面() {
    sleep.millisecond(5000)
    let 更多信息 = auto.nodeSearch(3000).desc("更多信息").className("android.widget.ImageView").clickable(true).longclickable(true);
    if (更多信息 != '') {
        更多信息.getNode(0).clickPoint();
        sleep.millisecond(1000)
        let refresh = auto.nodeSearch(3000).text("刷新").className("android.widget.TextView");
        if (refresh != '') {
            refresh.getNode(0).clickPoint();
            print.log("点击刷新");
        }
    }
}

function float() {
    let f = new floatUI();

    f.loadXML(`
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="80"
    android:layout_height="50"
    android:orientation="vertical">
    <Button
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="b1"
        android:text="退出" />
</LinearLayout>
    `)
    f.setTransparent()
    f.setPosition(0, 0)
    let b1 = f.findViewById('b1');
    b1.setOnClickListener(function () {
        f.runOnUiThread(() => {
            ac.close()
            f.close()
            logWindow.close()
            stopAll()
        });
    })
}